//添加cookie
function setCookie(c_name, value, expiredays)
{
    if(expiredays == null) expiredays = 30;
    var exdate = new Date()
    exdate.setDate(exdate.getDate()+expiredays)
    var cookieVal=c_name+ "=" +escape(value)+((expiredays == null) ? "" : ";expires="+exdate.toGMTString());
    document.cookie=cookieVal;
}
$(document).ajaxError(function(){
    $.mobile.hidePageLoadingMsg();
    alert('登陆失败');
})
$('#login input:button').live('click', function(){
    var username = $('input[name=username]').val();
    var password = $('input[name=password]').val();
    var keep = $('input[name=keep]').attr('checked');
    var expiredays = keep ? 30 : 1;
    $.mobile.showPageLoadingMsg('', '正在登陆中...');
    $.get('data.php?a=LOGIN&loginName='+username+'&passwd='+password, function(data){
        if(data['studentname'] != null){
            setCookie('LoginName', username, expiredays);
            setCookie('studentname', data.studentname, expiredays);
            setCookie('LcenterId', data.fdzJGCode, expiredays);
            window.location='index.php';
        }else{
            $.mobile.hidePageLoadingMsg();
            alert('登陆失败');
        }
    }, 'json')
})